// 所有用户管理
import { ADDUSER, UPDATEUSER, DELUSER } from '../action/usersAction'
const initialState = []
export default (state = initialState, { type, payload }) => {
    switch (type) {
        case ADDUSER:
            return [...state, payload]
        case UPDATEUSER:
            const { id, user } = payload
            return state.map(it => it.id === id ? { ...it, ...user } : it)
        case DELUSER:
            return state.filter(it => it.id !== payload)
        default:
            return state
    }
}
